<?php
	$sql = new db();
	$req = "SELECT co.*, en.Nom AS en_nom, cl.Raison_Social, us.Nom AS us_nom FROM entrepot AS en, usine AS us, commande AS co, client AS cl WHERE co.Id_Commande = ".$_GET['idcom']." AND cl.GLN_Client = co.GLN_Client AND co.GLN_DO = us.GLN_DO AND co.GLN_Entrepot = en.GLN_Entrepot";
	$sql->query($req);
	$res_com = $sql->fetch_array();
	switch($res_com['Etat']) 
	  {
	   case 'e':
	    $etat_val =  "En cours ...";
		break;
	   case 'v':
	    $etat_val =  "En cours ...";
		break;
	   case 'r': 
	    $etat_val = "Refus&eacute;e.";
		break;
	   case 'l':
	    $etat_val =  "Livrée !";
	    break;
	   case 'c':
	    $etat_val = "En cours ...";
	    break;
	   case 'p':
	    $etat_val =  "A traiter ...";
		break;
		case 's':
		$etat_val = "A livrer...";
		break;
		case 'd':
		$etat_val =  "En livraison...";
		break;
	  }
	$req = "SELECT pr.Date_diffusion_ordre_prepa, pr. Description, pr.Date_fin FROM preparation AS pr WHERE pr.Id_Commande = ".$_GET['idcom'];
	$sql->query($req);
	$res_pre = $sql->fetch_array();
	if (empty($res_pre))
		{
			$res_pre['Date_diffusion_ordre_prepa'] = "N/a";		
			$res_pre['Date_fin'] = "N/a";
		}
	$req = "SELECT (Couts_stock + Couts_fixes + Couts_traite) AS tot_entrepot, Couts_livraison FROM couts WHERE Id_Commande = ".$_GET['idcom'];
	$sql->query($req);
	$res_cout = $sql->fetch_array();
	if (empty($res_cout))
	{
		$res_cout['tot_entrepot'] = "N/a.";
		$res_cout['Couts_livraison'] = "N/a.";
	}
	else
	{
		$res_cout['tot_entrepot'] .= " &#128;";
		if ($res_cout['Couts_livraison'] == 0)
			$res_cout['Couts_livraison'] = "N/a.";
		else
			$res_cout['Couts_livraison'] .= " &#128;";
	}
	if (isset($_GET['idpal']) && !empty($_GET['idpal']))
	{
		$req = "SELECT Id_palette, li.Id_colis, Quantite FROM colis, ligne_commande AS li WHERE Id_palette =".$_GET['idpal']." AND li.Id_commande =".$_GET['idcom']." AND li.Id_colis = colis.Id_colis";
		$sql->query($req);
		$array = array();
		while ($res_pal = $sql->fetch_array())
			{
				$array[] = $res_pal;
			}
	}
?>